package com.liit.controller.weixin.controller;

import javax.inject.Inject;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.liit.entity.CommodityFormMap;
import com.liit.mapper.CommodityMapper;
import com.liit.plugin.PageView;
import com.liit.util.Common;

@Controller
@RequestMapping("/weixin/commodity/")
public class ComController extends WeixinBaseController {
	@Inject
	private CommodityMapper commodityMapper;

	@RequestMapping("list")
	public String list(Model model) throws Exception {
		return Common.BACKGROUND_PATH + "/weixin/user/listCommodity";
	}

	@ResponseBody
	@RequestMapping("findByPage")
	public PageView findByPage(String pageNow, String pageSize) throws Exception {
		CommodityFormMap commodityFormMap = getFormMap(CommodityFormMap.class);
		commodityFormMap.put("orderby", " order by createTime desc ");
		commodityFormMap = toFormMap(commodityFormMap, pageNow, pageSize, commodityFormMap.getStr("orderby"));
		pageView.setRecords(commodityMapper.findByPage(commodityFormMap));
		return pageView;
	}
}
